package com.example.mapper

import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.baomidou.mybatisplus.core.metadata.IPage
import com.example.entity.Product
import com.example.entity.User
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select

@Mapper
interface UserMapper : BaseMapper<User> {

    /**
     * 自定义分页（IPage<?>参数必须在第一位）
     * @param page 分页对象
     * @param age 年龄
     * @return 对象集合
     */
    @Select(
        """
        SELECT uid AS id, name AS username, age, email, create_time, update_time, is_deleted AS deleted
        FROM t_user 
        WHERE age > #{age}
        """
    )
    fun selectPageByAge(page: IPage<User>, @Param("age") age: Int): List<User>
}

@Mapper
interface ProductMapper : BaseMapper<Product>
